home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: redoFileKeyInsert.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:57 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "log.h"
- #include "pool.h"
- #include "volume.h"
- #include "logrecs.h"
- #include "trans.h"
- #include "bitmap.h"
- #include "file.h"
- #include "openlog.h"
- #include "bf_extfuncs.h"
- #include "bm_extfuncs.h"
- #include "fi_intfuncs.h"
- #include "trans_extfuncs.h"
- #include "redo_extfuncs.h"
- #include "logaction.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "log_globals.h"
- #include "log_extfuncs.h"
-
-
- void
- redoFileKeyInsert (
-
- LOGRECORDHDR *record
- )
- {
-
- register PID *pid;
- register FOUR *insertLoc;
- register SHORTPID *key;
- register NODEPAGE *nodePage;
- register GROUPLINK *nodeLink;
- register BOOL *large;
- DIRTYPAGEINFO *dirtyInfo;
-
-
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
-
- /*
- * get a pointer to the name in the record
- */
- pid = &(record->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
- /*
- * get a pointer to the name in the record
- */
- insertLoc = (FOUR *) GET_LOG_IMAGE(record, 0);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("insertLoc:%d", *insertLoc));
-
- /*
- * get a pointer to the name in the record
- */
- key = (SHORTPID *) GET_LOG_IMAGE(record, 1);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("key:%d", *key));
-
- /*
- * get a pointer to the large flag
- */
- large = (BOOL *) GET_LOG_IMAGE(record, 2);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("large:%d", *large));
-
- /*
- * check to see if the page is in the dirty page list
- */
- if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
- return;
- }
-
- /*
- * check to see if the lrc on the page is greater than
- * the lrc in the log record.
- * Also check the lsn for the case of pages which never made it
- * back from the client.
- */
- if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
-
- /*
- * don't need to redo
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
- return;
- }
-
- /*
- * Read in first page of file and grab node type
- */
- if ((nodeLink = bf_ReadPage(UserBufGroup, pid, FILE_PAGE2SIZE, BF_SEM)) == NULL) {
-
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
-
- /*
- * get a pointer to the node page
- */
- nodePage = (NODEPAGE *) nodeLink->bufFrame;
-
- /*
- * check to see if the lrc on the page is greater than
- * the lrc in the log record
- */
- if (compareLRC( &(record->actionLRC), &(nodePage->header.lrc)) <= 0) {
-
- /*
- * don't need to redo
- * mark the page lrc
- */
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
- dirtyInfo->lrc = nodePage->header.lrc;
-
- /*
- * release the page
- */
- signalSemaphore( &(nodeLink->pageHash->semaphore) );
- bf_UnfixPage(nodeLink, BF_DEFAULT, FALSE);
- return;
- }
-
- /*
- * insert the key
- */
- FI_InsertToArray(nodePage, *insertLoc, *key, NULLPID, *large);
-
- /*
- * mark the LRC on the page
- * Set up the firstLSN/LRC for the page
- */
- nodePage->header.lrc = record->actionLRC;
- DEPEND_LOG(nodeLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
- TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", nodePage->header.lrc.count));
-
- /*
- * release the page semaphore
- */
- signalSemaphore( &(nodeLink->pageHash->semaphore) );
-
- /*
- * release and dirty the page
- */
- bf_UnfixPage(nodeLink, BF_DEFAULT, TRUE);
- }
-